#region Summary

// 
// Owner : JackieHan 
// 
// Solution : ResearchTest 
// 
// Project : Jackie.Research.Wcf.Rest.Test
// 
// File : TestEchoService.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 测试Echo服务
// 
// History : 
//			2011-05-17 15:29:20	    Create 
// 

#endregion

#region Using

using System;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using Jackie.Research.Wcf.Rest.Contracts;
using Jackie.Research.Wcf.Rest.Domain;
using Jackie.Research.Wcf.Rest.Service;
using NUnit.Framework;

#endregion

namespace Jackie.Research.Wcf.Rest.Test
{
    /// <summary> 
    /// 测试Echo服务
    /// </summary>
    [TestFixture]
    public class TestEchoService
    {

        [SetUp]
        public void SetUp()
        {
        }

        [Test]
        public void TestWebChannelFactory()
        {
            using (var factory = new WebChannelFactory<IEchoService>(new Uri("http://localhost:3229/echo")))
            {
                //factory.Endpoint.Behaviors.Add(new WebHttpBehavior());
                var service = factory.CreateChannel();
                var s = service.EchoWithGet("Hello");
                Console.WriteLine(s);

                s = service.EchoWithPost("Hello");
                Console.WriteLine(s);

                var info = new EchoInfo() { Message = "Hello", SendTime = DateTime.Now };
                s = service.EchoWithPostObject(info);
                Console.WriteLine(s);

                var re = service.EchoWithPostObjectReturnObject(info);
                Console.WriteLine(re.Message);
                Console.WriteLine(re.SendTime);
            }
        }

        [TearDown]
        public void TearDown()
        {
        }

    }
}